package org.hbnu.xiaomi.service;

import org.hbnu.xiaomi.entity.Orders;
import org.hbnu.xiaomi.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service

public class OrdersService implements OrderMapper {
    @Autowired
     OrderMapper orderMapper;
    // 根据用户id查询用户订单
    @Override
    public List<Orders> selectOrdersByUserId(Integer user_id) {
        return orderMapper.selectOrdersByUserId(user_id);
    }

    @Override
    public int findGoodIdByOrderId(int goodId) {
        return orderMapper.findGoodIdByOrderId(goodId);
    }

    // 添加保存用户订单
    @Override
    public void insert(Orders orders) {
       orderMapper.insert(orders);
    }

    @Override
    public void deleteById(int id) {
        orderMapper.deleteById(id);
    }

    //收货
    @Override
    public int updateOrder(int id, int paid) {
        return orderMapper.updateOrder(id,paid);
    }
    //退货
    @Override
    public int productOrder(int id, int paid, int num) {
        return orderMapper.productOrder(id,paid,num);
    }

}
